﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Carmichael_inc.aspx.cs" Inherits="newBlog.CenterInc.view_inc.admin.Carmichael_inc" %>
<%@ Import Namespace="newBlog.CenterInc.Ctrltor" %>
<% 
    Response.ContentType = "application/json";
    if (Session["user_id"]==null) {
        Response.Write("{\"error\":\"您未登录本站\"}");
        return;
    }
    if (Convert.ToInt32(Session["user_grade"])!=1) { 
    Response.Write("{\"error\":\"您不是管理员\"}");
        return;
    }
    int mode = Request.Form["mode"]==null||Request.Form["mode"].Length==0?0:Convert.ToInt32(Request.Form["mode"]);//1生成卡密 2删除卡密
    string carmichael_id = Request.Form["carmichael_id"]==null||Request.Form["carmichael_id"].Length==0?"":Request.Form["carmichael_id"];//卡密id
    int nums = Request.Form["nums"]==null||Request.Form["nums"].Length==0?0:Convert.ToInt32(Request.Form["nums"]);//生成数量
    int price = Request.Form["price"]==null||Request.Form["price"].Length==0?0:Convert.ToInt32(Request.Form["price"]);//价格
    Pay_inc pay_Inc = new Pay_inc();
    switch (mode) {
        case 1:
            if (nums==0) {
                Response.Write("{\"error\":\"请输入数量\"}");
                return;
            }
            if (pay_Inc.CreateKeyValue(nums,price)) {
                Response.Write("{\"error\":\"创建卡密出现问题目前可能已经创建一些如不需要可以删除\"}");
                return;
            }
            Response.Write("{\"msg\":\"创建成功\"}");
            return;
        case 2:
            if (carmichael_id.Length==0) {
                Response.Write("{\"error\":\"id不能留空\"}");
                return;
            }
            if (pay_Inc.DelKeyValue(carmichael_id)) {
                Response.Write("{\"error\":\"删除失败\"}");
                return;
            }
            Response.Write("{\"msg\":\"删除成功\"}");
                return;
            return;
    }
    %>
